package cn.bonoon.kernel.menus;


public class TabItemDefinition extends XpathItemable implements ItemableDefinition{
	
	private final TabItemParser parser;
	private final TabsDefinition parent;

//	private PlatformContext platformContext;
	
	public TabItemDefinition(TabsDefinition parent, TabItemParser parser){
		this.parent = parent;
		this.parser = parser;
	}

	public TabItemDefinition(int ordinal, String id, String name, TabsDefinition parent, TabItemParser parser){
		this.id = id;
		this.name = name;
		this.ordinal = ordinal;
		this.parent = parent;
		this.parser = parser;
	}

	public TabItemParser getParser() {
		return parser;
	}

	public TabsDefinition getTabs() {
		return parent;
	}
	public void init(PlatformContext platformContext, ParentContainer parent) {
//		this.platformContext = platformContext;
		this.id = platformContext.combine(parent.getInternalId(), id);
		this.xpath = platformContext.xpathGenerate(parent.getXpath());
		this.parser.init(platformContext, this);
	}

	@Override
	public ModuleDefinition getModule() {
		return parent.getModule();
	}

	@Override
	public ChannelDefinition getChannel() {
		return parent.getChannel();
	}
	
//	@Override
//	public PlatformContext getPlatformContext() {
//		return platformContext;
//	}

//	@Override
//	public String checkable(MenuCheckable menuCheckable, boolean checked) {
//		switch (menuCheckable) {
//		case CHECKABLE:
//			StringBuilder htmlCheckable = new StringBuilder();
//			htmlCheckable.append("<input name='").append(parent.getId());
//			htmlCheckable.append("' class='").append(xpath);
//			htmlCheckable.append("' value='").append(id);
//			htmlCheckable.append("' id='").append(id);
//			if(checked){ htmlCheckable.append("' checked='checked"); }
//			htmlCheckable.append("' type='checkbox'/>");
//			return htmlCheckable.toString();
//		case READONLY:
//			return "<img src='" + platformContext.iconCheckable(checked) + "'/>";
//		case UNCHECKED:
//			StringBuilder htmlUncheckable = new StringBuilder();
//			htmlUncheckable.append("<input name='").append(parent.getId());
//			htmlUncheckable.append("' class='").append(xpath);
//			htmlUncheckable.append("' value='").append(id);
//			htmlUncheckable.append("' id='").append(id);
//			htmlUncheckable.append("' type='checkbox'/>");
//			return htmlUncheckable.toString();
//		}
//		return "";
//	}
}
